package com.lamatek.tags.google;

import java.io.Serializable;

import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;


public class GoogleMapImageOverlayTag extends TagSupport implements Serializable {

    String url = null;
    String link = null;
    int x = 0;
    int y = 0;
    float opacity = 0.50f;
    String id = null;
    /**
     * Overrides doStartTag() from TagSupport. Developers should not override this
     * method.
     */
    public int doStartTag() {
        Tag tag = this;
        while (tag.getParent() != null) {
            if (tag.getParent() instanceof GoogleMapTag) {
                ((GoogleMapTag) tag.getParent()).addImageOverlay(this);
                return SKIP_BODY;
            }
            tag = tag.getParent();
        }
        return SKIP_BODY;
    }
    /**
     * Returns the opacity level (0-1) of the image overlay. 0 is invisible,
     * 1 is fully opaque. Default is 0.50.
     * 
     * @return The opacity level as a float.
     */
    public float getOpacity() {
        return opacity;
    }
    /**
     * Sets the opacity level (0-1) of the image overlay. 0 is invisible,
     * 1 is fully opaque. Default is 0.50.
     * 
     * @param opacity The opacity level as a float.
     */
    public void setOpacity(float opacity) {
        this.opacity = opacity;
    }
    /**
     * Returns the x pixel location where the upper-left corner of the
     * image is placed. The location is relative to the map's upper-left hand
     * corner.
     * 
     * @return An int that represents horizontal location in pixels.
     */
    public int getX() {
        return x;
    }
    /**
     * Returns the y pixel location where the upper-left corner of the
     * image is placed. The location is relative to the map's upper-left hand
     * corner.
     * 
     * @return An int that represents vertical location in pixels.
     */
    public int getY() {
        return y;
    }
    /**
     * Sets the x pixel location where the upper-left corner of the
     * image is placed. The location is relative to the map's upper-left hand
     * corner.
     * 
     * @param x int that represents horizontal location in pixels.
     */
    public void setX(int x) {
        this.x = x;
    }
    /**
     * Sets the y pixel location where the upper-left corner of the
     * image is placed. The location is relative to the map's upper-left hand
     * corner.
     * 
     * @param y int that represents vertical location in pixels.
     */
    public void setY(int y) {
        this.y = y;
    }
    /**
     * Returns the url of the image to be displayed on the map.
     * 
     * @return a relative or absolute url to an image file.
     */
    public String getUrl() {
        return url;
    }
    /**
     * Sets the url of the image to be displayed on the map.
     * This can be a relative or absolute url.
     * 
     * @param url A valid relative or absolute url to an image file.
     */
    public void setUrl(String url) {
        this.url = url;
    }
    /**
     * Returns the unique id of this image overlay.
     * 
     * @return A unique id.
     */
    public String getId() {
        return id;
    }
    /**
     * Sets the id for this image overlay. It must be unique within the map.
     * 
     * @param id The id for this image overlay.
     */
    public void setId(String id) {
        this.id = id;
    }
    /**
     * Returns the url that will be hyperlinked if the overlay is clicked on.
     * 
     * @return A url that will be triggered if the image is clicked on.
     */
    public String getLink() {
        return link;
    }
    /**
     * Sets s hyperlink url that will be triggered if the overlay is clicked on.
     * 
     * @param link The url that will be called if the image is clicked on.
     */
    public void setLink(String link) {
        this.link = link;
    }
}
